package com.liao.controller;

import com.liao.bean.OrderCount;
import com.liao.bean.VisitList;
import com.liao.bean.result.Code;
import com.liao.bean.result.Msg;
import com.liao.bean.result.PageResult;
import com.liao.bean.result.Result;
import com.liao.service.OrderCountService;
import com.liao.service.OrderService;
import com.liao.service.VisitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/orderCount")
public class OrderCountController {

    /**
     * 分页模糊查询客户业绩表
     */
    @Autowired
    private OrderCountService orderCountService;

    @ResponseBody
    @RequestMapping("/queryOrderCountListByPage")
    public PageResult<OrderCount> queryOrderCountListByPage(Integer currentPage, Integer pageSize, String orderId) throws Exception {

      PageResult<OrderCount> pageResult=  orderCountService.queryOrderCountListByPage(currentPage,pageSize,orderId);

      return pageResult;
    }

    /**
     * 删除
     * @param ocid
     * @return
     */
    @ResponseBody
    @RequestMapping("/deleteOrderCountById")
    public Result deleteOrderCountById(String ocid) throws Exception {

        orderCountService.deleteOrderCountById(ocid);

        return new Result(true, Code.SERVERDEL_SUCCESS, Msg.SERVERDEL_SUCCESS,null);
    }

    /**
     * 批量删除
     * @return
     */
    @ResponseBody
    @RequestMapping("/deleteOrderCountByIdS")
    public Result deleteOrderCountByIdS(@RequestParam("ocids[]")List<String> ocids) throws Exception {

        for (String ocid : ocids) {
            orderCountService.deleteOrderCountById(ocid);
        }

        return new Result(true, Code.SERVER_DEL, Msg.SERVER_DEL,null);
    }

    /**
     * 添加

     * @return
     */
    @ResponseBody
    @RequestMapping("/addOrderCount")
    public Result addOrderCount(String ocid,String orderId,String orderMoney,String orderPMoney) throws Exception {

        orderCountService.addOrderCount(ocid,orderId,orderMoney,orderPMoney);

        return new Result(true, Code.SERVER_ADD, Msg.SERVER_ADD,null);
    }

    /**
     * 根据scid修改用户

     * @return
     */
    @ResponseBody
    @RequestMapping("/updateOrderCount")
    public Result updateOrderCount(String ocid,String orderId,String orderMoney,String orderPMoney) throws Exception {
        orderCountService.updateOrderCount(ocid,orderId,orderMoney,orderPMoney);

        return new Result(true, Code.SERVER_UPDATE, Msg.SERVER_UPDATE,null);
    }
}
